<?php defined('SYSPATH') or die('No direct script access.');

class Model_Article extends ORM {

    //Speed up the ORM
    // protected $_table_columns = array(
    //     'id'            =>  array('type'=>'int'),
    //     'title'          =>  array('type'=>'string'),
    //     'content'     =>  array('type'=>'string'),
    // );

     // contains many relations
    protected $_has_many = array(
        // an article has many comments
        'comments' => array(
            'model'     => 'comment',
            'foreign_key'   => 'article_id',
        ),
        'contents' => array(
            'model'     => 'articlecontent',
            'foreign_key'   => 'article_id',
        ),

    );

    /**
     * Rule definitions for validation
     *
     * @return array
     */
    // public function rules() {
    //     return array (
    //         'title' => array (
    //             array('not_empty'),
    //         ),
    //         'content' => array (     // property name to validate
    //             array('not_empty'),     // validation type
    //             array(
    //                 'min_length',       // validation type
    //                 array(':value', 10) // validation parameters
    //             ),
    //         ),
    //     );
    // }

    // public function labels() {
    //     return array(
    //         'title'         => 'Title',
    //         'content'       => 'Content',
    //     );
    // }
}